1. Field of the Invention
The present invention relates generally to graphics systems and, more particularly, to rasterization of a graphics primitive in a computer graphics system.
2. Related Art
Computer graphics systems are commonly used for displaying two- and three-dimensional graphical representations of objects on a two-dimensional video display screen. Current computer graphics systems provide highly detailed representations and are used in a variety of applications.
In a typical computer graphics system an object, or model, to be presented on the display screen is decomposed into graphics primitives. Primitives are basic components of a graphics display and include, for example, points, lines, triangles, quadrilaterals and polygons. Typically, a hardware/software scheme is implemented to render, or draw, the graphics primitives that represent a view of one or more objects being presented on the display screen.
Generally, a host computer defines primitives of a three-dimensional model in terms of primitive data. Typically, primitive data includes, but is not necessarily limited to, the X, Y, Z, and W coordinates of the primitive""s vertices, as well as the red, green, blue, and alpha (R, G, B, A) color values of each vertex of the primitive. Rendering hardware processes the primitive data to compute the display screen pixels that represent each primitive, and the color values for each pixel.
The basic components of a computer graphics system typically include a host computer and graphics hardware. The host computer executes a graphics application program that controls the graphics hardware, commonly through an application program interface (API). The API receives commands from the graphics application program and provides primitive data to the graphics hardware. The graphics hardware typically includes one or more geometry accelerators, a rasterizer, a frame buffer and, oftentimes, a texture mapper. The geometry accelerator receives primitive data from the host computer and performs operations such as coordinate transformations and lighting, clipping, and plane equation calculations for each primitive. The geometry accelerator generates rendering data that is used by the rasterizer and the texture mapper to generate final screen coordinates and color data for each pixel in each primitive.
Texture mapping permits objects to be displayed with improved surface detail. Texture mapping maps a source image, referred to as a texture, onto the surface of a three-dimensional object, and thereafter projects the textured three-dimensional object to the two-dimensional graphics display screen. Texture mapping involves applying one or more texture elements (texels) of a texture to each picture element (pixels) of the displayed portion of the object to which the texture is being mapped. Texture mappers typically include a local memory cache that stores texture mapping data associated with the portion of the object being rendered. The pixel data from the rasterizer and the texel data from the texture mapper are combined by the rasterizer and stored in the frame buffer by a frame buffer controller for display on a display screen.
Graphics systems typically model the effects of one or more light sources on three-dimensional objects when they are rendered. The ultimate color of a three-dimensional object is dependent on the quantity and characteristics of light shining on the object. Typically, the color of a light source is characterized by the quantity of red, green, and blue light it emits. Additional requirements are often necessary to provide an accurate lighting effect in a rendered image. In OpenGL, for example, a light source has an effect only when a surface reflects the light emitted by the light source. Each surface of an object is composed of a material having various properties. The material properties define the percentage of received red, green and blue light components that is reflected by the surface in various directions. The material properties of a surface thereby influence the effect that light striking the surface will have and, as a result, influence the colors used to render pixels representing the object surface.
Generally, four independent types of lighting are offered in conventional graphics systems. They are commonly referred to as diffuse, specular, emissive and ambient light. Diffuse light is light that comes from one direction. Diffuse light is brighter when it comes squarely down on a surface than when it barely glances off the surface. Once diffuse light hits a surface, however, it is scattered equally in all directions, appearing to be equally bright no matter where the viewer""s eye is located. Any light coming from a particular position or direction typically has a diffuse component. Specular light comes from a particular direction, and tends to bounce off a surface in a preferred direction. For example, a well-collimated laser beam reflected by a high-quality mirror produces almost 100 percent specular reflection in a specific direction. Shiny metal and plastic have a high specular component while chalk or carpet have almost none. Emissive light is light that is emitted by a material such as headlights on an automobile. Ambient light is light that has been scattered so much by the environment that its direction cannot be determined; that is, it seems to come from all directions. Traditionally, the red, green, and blue values for each type of lighting effect are determined and managed separately by the graphics application.
A common concern in the design of graphics systems is the size and cost of circuitry implemented in the rasterizer. Generally, a rasterizer converts each primitive into fragments by scan converting the vertex definitions of the primitive components to corresponding values at each pixel rendering the primitive. Each fragment includes a quantity of related data defining a pixel in the rendered image. Traditional graphics systems attempt to conserve circuitry and memory by combining certain components prior to rasterization. Commonly, two such components are the diffuse and specular lighting components. These two components are combined into a single, combined diffuse/specular lighting value that is subsequently rasterized. The final color value of a fragment is based on the product of the texture mapping component and this combined lighting component.
The inventors of the present application have observed drawbacks to this approach. One such drawback is that the reflectivity of a surface is scaled by the intensity of the surface texture. That is, the intensity of the texture determines not only the ultimate color value of a pixel, but also the effect of the specular lighting component on that surface. This approach does not produce accurate results for pixels having very low intensity values. Specifically, when traditional rasterizers produce pixels having minimal or no intensity value (for example, pixels with a black texture), the pixels are rendered black regardless of the value of the original specular lighting component. In other words, this approach fails to display dark surfaces as shiny or reflective even when the light impinging on that surface has a significant specular lighting component. This inability to render such surfaces reduces the realism of certain images.
The present invention is directed to a rasterizer and associated methodology that overcome the above and/or other drawbacks of conventional rasterization and graphics processing approaches. The invention implements a single edge stepping interpolator to interpolate both diffuse and specular lighting components across an edge of the primitive, and/or a single span stepping interpolator to interpolate both diffuse and specular lighting components across the spans of the primitive. When the edge or span being interpolated includes a non-negligible specular lighting component, the diffuse and specular lighting components are separately and successively rasterized. Otherwise, only the diffuse lighting component is interpolated over the edge or span. This enables the invention to achieve an optimal balance between the size and cost of the rasterizer circuitry and the efficiency with which primitives are rasterized.
The inventors have observed that of the millions of graphics primitives that may form a three-dimensional image, typically only a few primitives have a specular lighting component. That is, specular lighting is not a significant portion of most scenes because the vast majority of polygons that make a scene lack the appropriate direction and orientation relative to the rendered light sources to cause a specular lighting effect to occur. This has lead the inventors to conclude that transferring, storing, and processing specular lighting components to calculate pixel color values for pixels in most graphics primitives is unnecessary and constitutes an inefficient use of resources. To overcome the observed drawback of conventional rasterization approaches while taking advantage of the rare presence of specular lighting, the present invention separately rasterizes the specular lighting component of only those few graphics primitives having a non-negligible specular lighting component. The specular lighting component for the remaining majority of primitives is zero and, therefore, not processed.
Specifically, a rasterizer of the present invention implements a single interpolator circuit to separately scan convert both diffuse and specular lighting components across a scanned portion, such as a edge or a span, of the primitive. That is, for each type of interpolator implemented in the rasterizer, a single interpolator of the invention is used for interpolating both the diffuse and specular lighting components. This is in contrast with conventional rasterizers that implement a single interpolator to interpolate each component of the primitive across portions of the primitive. For example, a typical conventional rasterizer includes three edge steppers and three span steppers to interpolate the coordinates of a primitive along edges and spans, respectively, of the primitive.
When the interpolated portion of the primitive includes a non-zero specular lighting component, the single interpolator circuit separately and successively interpolates the diffuse and specular lighting components. Otherwise, only the diffuse lighting component is interpolated. Thus, rasterization of a primitive to its component pixels entails interpolating the diffuse and specular lighting components in separate and successive processing states, and doing so only when the primitive includes a specular lighting component greater than zero or some other negligible value. This requires two processing states rather than one to interpolate each fragment of those portions of the interpolated primitive having both lighting components. This decreases the efficiency with which those relatively few primitives are rasterized. However, by re-using the same interpolator circuitry to interpolate both diffuse and specular lighting components, the present invention accurately rasterizes scenes using a minimal amount of circuitry as compared to conventional systems, thereby reducing the relative size and cost of the rasterizer. Thus, the invention provides significant savings in rasterizer circuitry while insuring that all object surfaces, including those that have low color intensity, properly exhibit the specular lighting contribution, if any. These significant advantages are provided at an expense of reducing minimally the responsiveness of the implementing graphics system.
A number of aspects of the invention are summarized below, along with different embodiments that may be implemented for each of the summarized aspects. It should be understood that the embodiments are not necessarily inclusive or exclusive of each other and may be combined in any manner that is non-conflicting and otherwise possible. It should also be understood that these summarized aspects of the invention are exemplary only and are considered to be non-limiting.
In one aspect of the invention a rasterizer is disclosed. The rasterizer includes one interpolator to interpolate both diffuse and specular lighting component of each color component (for example, red, green, blue) of a graphics primitive, generating values for the diffuse and specular lighting color components at each fragment in a rasterized form of the primitive. Importantly, the interpolator consists of only one adder circuit element to perform interpolation functions. When the portion of the primitive being rasterized includes a non-negligible specular lighting component, the diffuse and specular lighting components are separately interpolated for each fragment of the interpolated portion of the primitive. When the primitive includes a negligible specular lighting component, only the diffuse lighting component is interpolated. Preferably, the specular lighting component is considered to be negligible when its color component values are zero.
In another aspect of the invention, a rasterizer to rasterize graphics primitives to their component pixels is disclosed. The rasterizer is constructed and arranged to process diffuse and specular lighting components of each pixel in separate and successive processing states, and does so only when an interpolated portion of the primitive comprising the pixels includes a specular lighting component greater than approximately zero. Typically, the lighting component is itself comprised of color components such as red, green and blue color components. In one embodiment, the rasterizer includes a scan converter and a control apparatus. The scan converter includes a plurality of interpolators. For each color component the interpolators include one interpolator that interpolate that color component of both diffuse and specular lighting components of the primitive. The control apparatus controls the scan converter such that for each fragment the scan converter separately and successively scan converts a diffuse lighting component and a specular lighting component of the primitive when the primitive includes a specular lighting component. When the primitive does not include a specular lighting component, the scan converter scan converts only the diffuse lighting component. In rasterizers that include interpolators that determine fragments along edges of the rasterized form of the primitive and interpolators that determine fragments in the interior of the rasterized form of the primitive, the single interpolator can either one or the other type of interpolator.
In a further aspect of the invention a rasterizer for converting graphics primitives represented by primitive data into fragments represented by one or more fragment data words is disclosed. Each fragment corresponds to a pixel of a rendered image and includes RGB and texture values for the pixel. The rasterizer includes a scan converter that scans each primitive defined by primitive data, converting the vertex definition of each primitive into fragments, each represented by one or two fragment data words. A control circuit configured to control the scan converter is also included. The control circuit causes the rasterizer to interpolate in two successive processing states the primitive data for any fragment in which the primitive data indicates that the fragment has a non-negligible specular lighting component. Preferably, the two successive processing states include a first processing state in which the control circuit determines the specular lighting component value for the fragment and a second processing state in which the control circuit determines the diffuse lighting component value for the fragment. In one embodiment, the control circuit controls the scan converter to interpolate the primitive data for a fragment in a single processing state in which the scan converter generates color values for the primitive without consideration of the specular lighting component of the primitive when the primitive data indicates that the primitive does not have a specular lighting component.
In a still further aspect of the invention, a rasterizer in a graphics system including at least one geometry accelerator is disclosed. The rasterizer includes a scan converter to receive graphics primitive signals descriptive of a graphics primitive to be rasterized and to generate graphics fragment signals from the graphics primitive signals. The graphics primitive signals include lighting component signals which, in turn, include diffuse lighting component signals indicating a diffuse lighting component of the graphics primitive and specular lighting component signals indicating a specular lighting component of the graphics primitive. A controller receives the specular lighting component signals and transmits command signals to the scan converter to instruct the scan converter to process the lighting component signals in a one-state mode when the specular lighting component indicated by the specular lighting component signals is negligible and to process the lighting component signals in a two-state mode when the specular lighting component indicated by the specular lighting component signals is non-negligible. A fragment processor generates color values for fragments of the graphics primitive to be rendered based the graphics fragment signals, the fragment processor generating the color values under instruction of the controller in the one-state mode when the specular lighting component indicated by the specular lighting component signals is negligible and to generate the color values in the two-state mode when the specular lighting component indicated by the specular lighting component signals is non-negligible.
In a still further aspect of the invention, a rasterizer for use in a graphics system is disclosed. The rasterizer includes a single processing channel configured to rasterize diffuse and specular lighting components of a graphics primitive in successive processing states only under the conditions when the graphics primitive includes a specular lighting component and a diffuse lighting component.
In another aspect of the invention, a method for rasterizing primitives of a graphics image is disclosed. The method includes the steps of: 1) determining, for each pixel of the primitive, whether the pixel includes a specular lighting component having a value greater than zero; 2) when the specular lighting component has a value greater than zero, processing a diffuse lighting component and a specular lighting component in separate and successive processing states; and 3) when the specular lighting component has a value of zero, processing only a diffuse lighting component of the pixel.
Various aspects of the present invention and embodiments thereof provide certain advantages and overcome certain drawbacks of conventional techniques. Not all aspects and embodiments share the same advantages and those that do may not share them under all circumstances. These disclosed aspects, some of which are summarized below, are not to be construed as limiting in any regard; they are provided by way of example only and in no way restrict the scope of the invention.